#使用openai的官方sdk
import openai
from openai import OpenAI
import os

# print(os.getenv("OPENAI_KEY"))
# print(os.getenv("OPENAI_API_BASE"))

api_key = os.getenv("OPENAI_API_KEY")
base_url = os.getenv("OPENAI_API_BASE")
timeout=120

client = OpenAI(api_key=api_key, base_url=base_url, timeout=timeout)

messages = [
{"role": "user", "content": "介绍下你自己"}
]

response = client.chat.completions.create(model="gpt-3.5-turbo", messages=messages)

# print(res['choices'][0]['message']['content'])
print( response.choices[0].message.content)